<?php
class WeiboCommendWidget  extends CWidget{
    
	//输出字符串
	private $commend = '';
    //文章类型
    public $type = '';
    //文章地址
    public $url = '';
    //文章标题
    public $title = '';
    //文章描述
    public $description = '';
    //文章创建时间
    public $createDate = '';
    //文章更新时间
    public $updateDate = '';
    //文章要显示的图片
    public $imageUrl = '';
    
    private $controller= '';
    
    private $action= '';

	public function init(){
        $this->controller = Yii::app()->controller->id;  
        $this->action = Yii::app()->controller->action->id; 
	}
	public function run(){
        $this->weiboCommend();
		echo $this->commend;
	}

	public function weiboCommend(){
		$this->title = addslashes($this->title);
		$this->description = addslashes($this->description);
		$this->createDate = date('Y-m-d H:i:s O',strtotime($this->createDate));
		$this->updateDate = date('Y-m-d H:i:s O',strtotime($this->updateDate));

        $this->commend = <<<COMMEND
<!-- sina微博 -->
        <meta property="og:type" content="{$this->type}" />
        <meta property="og:url" content="{$this->url}" />
        <meta property="og:title" content="{$this->title}" />
        <meta property="og:description" content="{$this->description}" />
        <meta name="weibo: webpage:create_at" content="{$this->createDate}" />
        <meta name="weibo: webpage:update_at" content="{$this->updateDate}" />\n
COMMEND;
    }
}


